package com.cong.leetcode.com.cong.hj;


import java.util.Scanner;
import java.util.PriorityQueue;
public class Main {
    private static Person first;
    public static void main(String[] args) {
        Scanner in = new Scanner("3");
        int m = in.nextInt();
        if (m <= 1 || m >= 100) {
            System.out.println("ERROR");
            return;
        }
        first = null;
        Person pointer = null;
        // build circle
        for (int i = 0; i < 100; i++) {
            Person p = new Person(i + 1);
            if (i == 0) {
                first = p;
                pointer = p;
                continue;
            }
            // i != 0
            pointer.next = p;
            p.prev = pointer;
            pointer = pointer.next;
            if (i == 99) { // last
                p.next = first;
                first.prev = p;
            }
        }
        pointer = first;
        // remove person
        int count = 100;
        while (count >= m) {
            pointer = removeOnePerson(pointer, m);
            count--;
        }

        // print person
        pointer = first;
        StringBuilder sb = new StringBuilder();
        do {
            sb.append(pointer.originNum ).append(",");
//            System.out.println(": " + pointer.originNum);
            pointer = pointer.next;
        }while (pointer != first);
        sb.deleteCharAt(sb.length() - 1);
        System.out.println(sb.toString());


    }
    static Person removeOnePerson(Person pointer, int m) {
        for (int i = 0;i < m -1;i++) {
            pointer = pointer.next;
        }
        Person prev = pointer.prev;
        Person next = pointer.next;
        prev.next = next;
        next.prev = prev;
        pointer.prev = pointer.next = null;
        if (first == pointer) first = next;
        return next;
    }
    static class Person {
        int originNum;
        Person next;
        Person prev;
        Person(int originNum) {
            this.originNum = originNum;
        }
    }
}